Mega Code Archive

Categories
1) Android
2) ASP.Net
3) ASP.Net Tutorial
4) C
5) C Tutorial
6) C#
7) C# Book
8) C# by API
9) C# Tutorial
10) C++
11) C++ Tutorial
12) Delphi
13) Flash ActionScript
14) Flex
15) Java
16) Java Book
17) Java by API
18) Java Tutorial
19) JavaScript DHTML
20) JavaScript Reference
21) JavaScript Tutorial
22) MSOfficeExcel 2007 Tutorial
23) MSOfficePowerPoint 2007 Tutorial
24) MSOfficeWord 2007 Tutorial
25) MSSQL
26) MSSQL Tutorial
27) MySQL
28) MySQL Tutorial
29) Oracle PLSQL
30) Oracle PLSQL Tutorial
31) Perl
32) Php
33) PostgreSQL
34) Python
35) Python Tutorial
36) Ruby
37) Silverlight
38) VB.Net
39) VB.Net by API
40) VB.Net Tutorial
41) Visual C++ .NET
42) VisualBasic Script
43) XML
44) XML Tutorial
 
Php
1) Algorithms
2) Authentication
3) Calendar
4) Chart
5) Class
6) Code Snippets
7) Components
8) Content Management
9) Cookie Session
10) Data Type
11) Date Time
12) Design Patterns
13) Development
14) DNS
15) Email
16) File Directory
17) Form
18) Functions
19) Graphics
20) HTML
21) Language Basics
22) Login Authentication
23) Math
24) MySQL Database
25) Network
26) Operator
27) PDF
28) Reflection
29) Searching
30) Site Navigation
31) Statement
32) Statistics and Counters
33) Strings
34) User Management
35) Web Services SOAP WSDL
36) XML
Strings
1) $
2) $0 is set to the whole match, then $1, $2
3) ^ and $ are line anchors
4) A function that parses a string and replaces
5) A function to take a string and converts the first letter of all words to upper case
6) A negative substr() length parameter
7) A non-capturing optional subpattern
8) A period ( ) character is used to combine two separate variables into a single string
9) A positive substr() length parameter
10) A regular expression for e-mail string checking
11) A simple use of preg_match()
12) A string and an integer value are added, and the result is an integer value
13) A third parameter to strpos( ) that allows us to specify where to start searching from
14) A very useful function to display text on specified number of characters
15) Accessing Substrings
16) Adding s to the end of the variable name
17) Addslashes()
18) An alternative to base_convert()
19) An Escape
20) Array str_split ( string string [, int split_length] )
21) ASCII Table
22) B and B, equate to On a word boundary and Not on a word boundary, respectively
23) Back-reference parenthesized substrings
24) Brackets [] finds a range of characters
25) Break $url down into three distinct pieces
26) By supplying no start or length arguments, the string will be added to the beginning
27) Calculating a date interval with strtotime()
28) Calculating average word length
29) Calculating the length of a string
30) Capitalizing letters
31) Capturing HTML headings
32) Capturing Text Inside HTML or XML Tags
33) Capturing with nested parentheses
34) Capturing with preg_match()
35) Case
36) Case-insensitive Pattern Matching
37) Case-insensitive version of str_replace( )
38) Case-sensitive
39) Change String case to lower
40) Change String case to Upper
41) Changing case
42) Changing case of strings
43) Character Classes
44) Chdir() function changes to the file directory
45) Check quotes in a file
46) Check string password
47) Checking a date range
48) Checking for an integer
49) Checking for Similar Names
50) Checking String Length
51) Checking the length of a trimmed string
52) Checking the syntax of an e-mail address
53) Chop() function returns a string minus any ending whitespace and newlines
54) Cleaning Up a String with trim(), Itrim(), and strip_tags()
55) Combine an expression with a string
56) Combine patterns with the pipe () character to create branches
57) Combining a string and a number
58) Combining trim() and strlen()
59) Compare string
60) Comparing Phrases
61) Comparing Sound
62) Comparing strings
63) Comparing strings case-insensitively
64) Comparing strings with strcmp()
65) Comparing strings with the equality operator
66) Complete list of regular expression examples
67) Concatenating strings together
68) Concatenation operator ( )
69) Concatenation with a here document
70) Concisely checking the length of a trimmed string
71) Controlling Case
72) Converting Case
73) Converting Line Breaks
74) Count_chars php
75) Counting the Occurrences of a Substring
76) Crypt
77) Curly offset syntax
78) Currency
79) Decoding HTML Entities
80) Define a pattern and use parentheses to match individual elements within it
81) Defining a here document
82) Detecting whether a string is contained in another string
83) Detecting ZIP Codes in Strings
84) Determine the similarity between two strings is provided by the similar_text function
85) Discarding empty elements with preg_split()
86) Displaying elements of $regs array
87) Dividing a String into Tokens with strtok()
88) Double quotation marks allow the parsing of variables
89) Double-quoted string escape sequences
90) Double-quoted strings
91) E modifier treats the replacement string in preg_replace() as if it were PHP
92) Easy Display of Dollars
93) Echo
94) Efficiently finding lines that match a pattern
95) Embed variables directly into strings
96) Embedded Conditionals
97) Embedding numbers and strings into other strings
98) Entity encoding matched text
99) Ereg php
100) Ereg() function searches a string, returning true if the pattern is found, and false otherwise
101) Ereg_replace
102) Ereg_replace php
103) Ereg_replace() function searches for string and replaces pattern if found
104) Ereg_replace-2
105) Eregi php
106) Eregi() function searches a string for another string
107) Escape a character in HTML
108) Escape Characters in PHP
109) Escape Characters That Act As Anchors
110) Escape sequences and their meanings (continued)
111) Escaping Special Characters
112) Explode
113) Extracting a substring with substr()
114) Extracting Part of a String with substr()
115) Extracting text from HTML tags
116) Extracting the end of a string with substr()
117) Fetching a URL with cURL
118) Filling Patterns with ereg
119) Find the First monday on or after November 1, 2008
120) Find the first p string and match as many characters as possible until the last possible t is reached
121) Find weekday
122) Finding a substring with strpos()
123) Finding a Substring Within a String with strstr()
124) Finding All Matching Lines in a File
125) Finding Lines with an Odd Number of Quotes
126) Finding Matches Globally with preg_match_all()
127) Finding Repeated Words
128) Finding the Date for a Weekday
129) Finding the Length of a String with strlen()
130) Finding the nth match
131) Finding the nth Occurrence of a Match
132) Finding the Position of a Substring with strpos()
133) Finding Words Not Followed by Other Words
134) Fixing quote escaping in backreference replacements
135) For example, using my collation rules (Canadian-English), I obtain the following results
136) Formatting a Phone Number
137) Generating date-based drop-down menu options
138) Generating replacement strings with a callback function
139) Generating replacement strings with an anonymous function
140) Get the start and end of the string when m is enabled, you should use A and z, like this
141) Getting an individual byte in a string
142) Getting the Day and Week of the Year
143) Getting the title of a remote page
144) Greedy and non-greedy matching
145) Greedy Qualifiers
146) Greedy versus nongreedy matching
147) Grouping captured subpatterns
148) How preg_split() can be used
149) I renders the regular expression non case sensitive
150) If PHP is unable to convert your string into a timestamp, it will return -1
151) If you pass substr() a negative number, it counts from the end of the string
152) If you use single quotation marks to enclose the same string, the variable is not substituted
153) If you want to generate a random password for any use you can use this function
154) Implementing a phrase-substitution algorithm
155) Implementing Custom Type Hinting
156) Implode
157) In some application youll need to have zero filled values for example
158) Indexing Strings
159) Initial-capping words is a very common task
160) Int ord ( string str ) returns the equivalent ASCII value
161) Int strcasecmp ( string str1, string str2 ) is a case-insensitive version of the strcmp( )
162) Int strcmp ( string str1, string str2 ), case-insensitive sibling, strcasecmp( )
163) Int strlen ( string str ) returns the number of characters in it
164) Int strpos ( string haystack, mixed needle [, int offset] ) returns the index of the beginning of a substrings first occurrence wit
165) Int strtotime ( string time [, int now] ) converts strings to a timestamp
166) Integer displayed as a dollar amount set to two decimal places
167) Integral that the value be displayed as a dollar amount set to two decimal places
168) Interpolating in a here document
169) Interpolating with curly braces
170) It is safe to use non-escaped Windows-style filenames in your single-quoted strings
171) Joining and Disassembling Strings
172) Left padding using the default of spaces
173) Limit string length and display
174) Limiting the number of returned elements with preg_split()
175) Line Anchors
176) Looking for any lowercase alphabetical character or the numbers 3, 4, and 7
177) Ltrim() function removes the whitespace and special characters from the left side of string
178) Ltrim() function to strip white space only from the beginning of a string
179) M modifier
180) Make use of str_pad()s optional parameters
181) Making a quantifier match as few characters as possible
182) Match an IP address
183) Match the smallest number of characters starting with p and ending with t
184) Match URL
185) Matching a Valid E-mail Address
186) Matching a Valid IP Address
187) Matching GUIDsUUIDs
188) Matching Patterns with preg_match()
189) Matching using backreferences
190) Matching with
191) Matching with character classes and anchors
192) Matching with Greedy vs Nongreedy Expressions
193) Matching with preg_match()
194) Matching with preg_match_all()
195) Metaphone function
196) Mixed count_chars ( string str [, int mode] ) returns an array containing the letters used in that string and how many times each l
197) Mixed str_replace ( mixed needle, mixed replace, mixed haystack [, int &count] )
198) Mixed str_word_count ( string str [, int count_type [, string char_list]] ) returns the number of words in a string
199) Modifying capitalize( ) to take a reference parameter
200) More here documents
201) Negate the characters in the character class
202) Nl2br
203) Nongreedy Qualifiers
204) Obtaining the Difference Between Two Dates
205) OK, so this is a simple word filter I made for use in any application like
206) Option patterns
207) Pad a string to a certain length with another string
208) Parsing a date with a regular expression
209) Parsing a date with preg_split()
210) Parsing a Query String
211) Pass a fourth parameter to preg_replace( ) to specify the maximum number of replacements you want to make
212) Pass arrays as parameter one and parameter two, and preg_replace() performs multiple replaces
213) Pass arrays of regular expressions and replacement strings to preg_replace()
214) Pattern match extenders
215) Pattern matches
216) Perl-Compatible Regular Expressions (PCRE)
217) PHP 5 Substring Functions
218) PHP has two main functions for performing simple search-and-replace operations The first one is substr_replace
219) POSIX Regular Expressions Character Classes
220) Predefined Character Ranges (Character Classes)
221) Preg_grep
222) Preg_grep() function searches all elements of input_array, returning all elements matching the regexp pattern
223) Preg_match
224) Preg_match( ) calls and what they match
225) Preg_match() function returns true if pattern exists, and false otherwise
226) Preg_match_all
227) Preg_match_all demo
228) Preg_match_all searches a string for all the occurrences of a regular expression
229) Preg_match_all() function matches all occurrences of pattern in string
230) PREG_OFFSET_CAPTURE and preg_match()
231) Preg_quote
232) Preg_replace
233) Preg_replace with index
234) Preg_split (+{1,})
235) Preg_split php
236) Preg_split() Flags
237) Preg_split() function operates like split(), except that regular expressions are accepted as input parameters for pattern
238) Prettifying names with ucwords()
239) Print
240) Printing HTML with a here document
241) Processing each byte in a string
242) Put the word boundary character to the test
243) Qualifiers restrict the number of times the preceding expression may appear
244) Quantifier Syntaxes
245) Quantifiers
246) Quantifiers for Matching a Recurring Character
247) Quickly finding lines that match a pattern
248) Quote escaping in backreference replacements
249) Quotemeta()
250) Ranges
251) Reading Fixed-Width Delimited Data
252) Reading Records with a Delimiter
253) Regular Expression Replacements
254) Regular expressions using +, , and
255) Regular expressions using braces
256) Regular expressions using character classes
257) Remove any doubled-up whitespace
258) Remove URL Parameter Substr Strstr
259) Replace any non-space whitespace, with a space
260) Replace the tag content without getting rid of any attributes
261) Replace with regular expression
262) Replacing a Pattern with a Found String
263) Replacing a Portion of a String Using substr_replace()
264) Replacing a substring with substr_replace()
265) Replacing Substrings
266) Replacing Substrings Using str_replace()
267) Replacing Tabs with Spaces
268) Replacing URLs with Links
269) Replacing using backreferences
270) Replacing with preg_replace()
271) Return String found at position 22
272) Reversing a string by byte
273) Reversing Strings
274) S modifier
275) See what portion of a string is composed only of a given set of characters
276) Setting up and working with both strings and substrings
277) Short text sample from long text articles
278) Single-character substitutions
279) Some string examples
280) Sorting Strings
281) Special classes for regular expression
282) Specify a negative number as parameter three for the length
283) Specify the characters in charlist by giving their hexadecimal value
284) Split php
285) Split() function divides a string into various elements
286) Splitting a String Based on a Found String
287) Sprintf print values to a string
288) Sprintf()s built-in hex-to-decimal conversion with the %x format character
289) Storing a Formatted String
290) Str_pad
291) Str_pad php
292) Str_pad() function pads string to length pad_length with a specified characters
293) STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH
294) Str_pad-2 php
295) Str_replace
296) Str_replace demo
297) Str_replace php
298) Str_replace() accepts arrays for all its arguments
299) Str_replace() function searches for occurrence in string, replacing all instances with replacement
300) Str_word_count php
301) Str_word_count-2 php
302) Strcasecmp
303) Strcasecmp() function operates like strcmp(), except that its comparison is case insensitive
304) Strcmp() function performs a case-sensitive comparison of two strings
305) Strcspn demo
306) Strcspn($password, 1234567890)
307) Strcspn() function returns the length of the first segment in string1 containing characters not in string2
308) String addslashes ( string str ) adds more and more slashes
309) String chr ( int ascii_val ) converts an ASCII number to its character equivalent
310) String compare
311) String compare demo
312) String compare with if statement
313) String Concatenation Operators
314) String contains string
315) String find Demo
316) String match and if statement
317) String match demo
318) String match for domain name
319) String matches
320) String Operators summary table
321) String Repeat Demo
322) String replace
323) String replace with Regular Expressions
324) String rtrim ( string str [, string trim_chars] ) only trims whitespace from the righthand side of a string
325) String SQL command escape
326) String str_pad ( string input, int length [, string padding [, int type]] )
327) String string token value
328) String strip_tags ( string html_text [, string allowed_tags] ) strips HTML and PHP tags from a string
329) String stripslashes ( string str ) is the opposite of addslashes( )
330) String strstr ( string haystack, string needle ) finds the first occurrence of a substring inside another string (parameter one).tx
331) String strtolower ( string str ) returns that string entirely in lowercase characters
332) String strtoupper ( string str ) returns that string entirely in uppercase characters
333) String substr ( string str, int start_pos [, int length] ) reads part of a string and takes a minimum of two parameters
334) String token
335) String token for string split
336) String trim ( string str [, string trim_chars] ) strips spaces, new lines, and tabs
337) String trim chop and length
338) String ucfirst ( string str ) converts the first letter of the string to an uppercase character
339) String ucwords ( string str ) converts the first letter of each word in the string to an uppercase character, leaving the others un
340) String word count
341) String word count and frequency
342) String wordwrap ( string str [, int line_length[, string break_char [, bool cut]]] )
343) String wordwrap ( string str [, int width [, string break [, bool cut]]] )
344) Strip all except a few tags
345) Strip_tags
346) Strip_tags php
347) Strip_tags() function removes all HTML and PHP tags from string, leaving only the text entities
348) Strip_tags() function, first argument is the text to transform
349) Stripping HTML tags from a string
350) Strlen php
351) Strpos
352) Strpos( ) will return false (as opposed to -1)
353) Strpos() function finds the position of the first occurrence in string
354) Strrpos php
355) Strrpos() function locates the last occurrence of character in string
356) Strspn
357) Strspn php
358) Strspn() function returns the length of the first segment in string1 containing characters also in string2
359) Strstr function demo
360) Strstr php
361) Strstr() function returns the remainder of string beginning at the first occurrence
362) Strtok php
363) Strtok() function performs a similar task to explode()
364) Strtok() function tokenizes string, using the characters specified in tokens
365) Strtolower php
366) Strtolower() function converts a string to all lowercase letters
367) Strtoupper php
368) Strtoupper()
369) Strtr php
370) Strtr() function converts all characters contained in destination to their corresponding character matches in source
371) Sub String Replace
372) Submitted string lowercase with strtolower() before invoking ucwords()
373) Substr php
374) Substr($string, 3)
375) Substr($String, 3, 5)
376) Substr($String, -3, 5) (2)
377) Substr($String, -3, -5) (3)
378) Substr($String, 3, -5) (4)
379) Substr() function returns the part of the string between the start and start+length parameters
380) Substr_count php
381) Substr_count() function returns the number of times substring occurs in string
382) Substr_replace php
383) Substr_replace() function replaces the string with replacement
384) Substr-2 php
385) Substr-3 php
386) Substring count
387) Substring replace
388) Subtracts a year from a given timestamp
389) Supply 1 as a fourth parameter, which enables cut modewords over the limit will be cut up if this is enabled
390) Supported String Delimiters
391) Switching tabs and spaces
392) Testing for Substrings
393) Testing the Complexity of Passwords
394) The m modifier to change the behavior of $
395) The soundex algorithm is implemented in PHP through the soundex function
396) There is an optional third parameter to str_pad( ) that lets you set the padding character to use
397) This function allows you to take any string and split it into fairly even pieces
398) To embed a single quote in a singly quoted string, escape it with a backslash
399) Trim Function
400) Trim only tab and newline characters from $str
401) Trim() function removes all whitespace from both sides of string
402) Trimming Strings
403) Trimming Strings for tab and return
404) Truncating a string with substr()
405) Truncating Text on Word Boundaries
406) Ucfirst php
407) Ucfirst() function capitalizes the first letter of a string
408) Ucwords php
409) Ucwords() function capitalizes the first letter of each word in a string
410) Ucwords() makes the first letter of every word in a string uppercase
411) Use more than one delimiter to split string
412) Use regular expression to check each line of the code
413) Use regular to check email address
414) Use split() to limit a parameter to restrict division of $ip
415) Using {x} notation with strings to read or write individual characters
416) Using a sprintf()-style message catalog
417) Using Back References with preg_replace()
418) Using ereg_replace
419) Using Escaped Characters
420) Using forward slashes on Windows
421) Using left space padding
422) Using left zero padding
423) Using negative lengths allows you to say copy everything but the last three characters
424) Using preg functions
425) Using preg_grep()
426) Using preg_match to return an array of matches that start with ple
427) Using preg_match_all() to Match a Pattern Globally
428) Using preg_replace() to Replace Patterns
429) Using preg_replace_callback() to Replace Patterns
430) Using preg_split()
431) Using preg_split() to Break Up Strings
432) Using several functions together to extract a portion of a string
433) Using sprintf with a variable
434) Using sprintf() to ensure that one digit hex numbers (like 0) get padded with a leading 0
435) Using str_replace()
436) Using strcasecmp to compare two strings
437) Using String Matching vs Pattern Matching
438) Using strtotime()
439) Using strtotime() with a starting epoch timestamp
440) Using substr() with length past the end of the string
441) Using substr() with negative length
442) Using substr() with negative start
443) Using substr() with positive $start and $length
444) Using substr() with positive start and no length
445) Using Substring Alternatives
446) Using template file
447) Using the word case functions
448) Validate email
449) Validating a credit card number
450) Validating an integer with typecasting
451) Validating numbers with regular expressions
452) Validating Pascal Case Names
453) Validating U S Currency
454) Various special characters in string assignments
455) What happens when multiple instances of the search string overlap
456) Word count like function Ver.1.0! This function can count your input text
457) Words and Whitespace Regexps
458) Wordwrap() doesnt break at your line limit if a word has more characters than the limit
459) Wordwrap() has two more optional arguments
460) Wordwrap() requires one argument, the string to be transformed
461) Wrap these in a couple of functions and surround the joined array elements with parentheses
462) Wrapping Text
463) Writing a response body to a file with cURL